//
//  ViewController.m
//  UI
//
//  Created by MAC on 15-11-9.
//  Copyright (c) 2015年 m. All rights reserved.
//

#import "ViewController.h"
#import "ViewController.h"
#import "TextViewController.h"

@interface ViewController ()
{
    UILabel * l;
}
@end

@implementation ViewController

- (void)viewDidLoad
{
    [super viewDidLoad];
	self.view.backgroundColor = [UIColor whiteColor];
    l = [UILabel new];
    l.text = @"你好，世界!";
    [l sizeToFit];
    l.center = CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.height/2.0);
    l.textColor = [UIColor greenColor];
    [self.view addSubview:l];
    
    //按钮
    UIButton * btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
    btn.frame = CGRectMake(100, 150, 100, 44);
    [btn setTitle:@"通讯录" forState:UIControlStateNormal];
    
    [btn setTitleColor:[UIColor blackColor] forState:UIControlStateNormal];
    
    [btn addTarget:self action:@selector(onClick:) forControlEvents:UIControlEventTouchUpInside];
    //[btn setTitle:@"你按下了！" forState:UIControlStateSelected];
    [self.view addSubview:btn];
    
}

- (void) onClick:(id)sendr
{
    TextViewController * con= [TextViewController new];
    [self.navigationController pushViewController:con animated:YES];
    
    
}

//动画
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];
    [UIView animateWithDuration:2.6 animations:^{
        l.center = CGPointMake(self.view.frame.size.width/2.0, self.view.frame.size.height - 50);
    }];
    
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
